<?php 
namespace Teacher\Controller;

use Admin\Controller\AdminbaseController;
class SignController extends AdminbaseController{
	
	protected $m;
	protected $udr;
	protected $lst;
	
	function _initialize() {
		parent::_initialize();
		$this->m = D('YgclSign');
		$this->udr = D('UsersDistrictRelation');
		$this->lst = D("LessonStudentRelation");
	}
	
	public function index(){
		$this->uid = $this->curUser['uid'];
		$cid = I('cid');
		$m = D('YgclClass');
		$mm = D('YgclLesson');
		$lesson = $mm->where(array('cid'=>$cid))->relation(true)->order('listorder desc')->select();
		$this->datas = $lesson;
		$this->display();
	}
	
	public function slist(){
		$this->display();
	}
	
	
	public function edit(){
		if(isset($_GET['id'])){
			$info = $this->m->find($_GET['id']);		
			$this->info = $info;
			
			$lid = $info['lid'];
		}else{
			$lid = I('lid');
		}
		
		$this->lid = $lid;
		$students = R('Api/Lessonapi/get_students_by_now_xnid',array($lid));
		$this->students = $students;
		$this->uid = $this->curUser['uid'];
		//$this->ids = implode(',', i_array_column($students,'id'));
		$this->display();
	}
	
	
	public function del(){
		$id = array_unique((array)I('ids',0));
		if ( empty($id) ) {
			$this->error('请选择要操作的数据!');
		}
		$map = array('id' => array('in', $id));
		if($this->m->where($map)->delete()){
			$this->success('删除成功');
		} else {
			$this->error('删除失败！');
		}
	}
	
	public function listorders() {
		$status = parent::_listorders($this->m);
		if ($status) {
			$this->success("排序更新成功！",U('index'));
		} else {
			$this->error("排序更新失败！");
		}
	}
	
	public function changestatus(){
		$data[$this->m->getPk()] = $_REQUEST['id'];
		$data['status'] = $_REQUEST['status'];
		$data['update_time'] = date('Y-m-d H:i:s');
		if($this->m->save($data)){
			$this->success('状态更新成功');
		}else{
			$this->error('状态更新失败');
		}
	}
	
}

?>